from alg import Solution
import random

def test_reverse_bits():
    solution = Solution()
    
    # 测试用例1：普通数字
    num1 = 43261596  # 00000010100101000001111010011100
    print(f"测试用例1:")
    print(f"原始数字: {num1}")
    print(f"二进制表示: {bin(num1)[2:].zfill(32)}")
    result1 = solution.reverseBits(num1)
    print(f"颠倒后数字: {result1}")
    print(f"颠倒后二进制: {bin(result1)[2:].zfill(32)}")
    print()
    
    # 测试用例2：全1
    num2 = 0xFFFFFFFF
    print(f"测试用例2:")
    print(f"原始数字: {num2}")
    print(f"二进制表示: {bin(num2)[2:].zfill(32)}")
    result2 = solution.reverseBits(num2)
    print(f"颠倒后数字: {result2}")
    print(f"颠倒后二进制: {bin(result2)[2:].zfill(32)}")
    print()
    
    # 测试用例3：全0
    num3 = 0
    print(f"测试用例3:")
    print(f"原始数字: {num3}")
    print(f"二进制表示: {bin(num3)[2:].zfill(32)}")
    result3 = solution.reverseBits(num3)
    print(f"颠倒后数字: {result3}")
    print(f"颠倒后二进制: {bin(result3)[2:].zfill(32)}")
    print()
    
    # 测试用例4：随机数字
    num4 = random.randint(0, 0xFFFFFFFF)
    print(f"测试用例4 (随机数):")
    print(f"原始数字: {num4}")
    print(f"二进制表示: {bin(num4)[2:].zfill(32)}")
    result4 = solution.reverseBits(num4)
    print(f"颠倒后数字: {result4}")
    print(f"颠倒后二进制: {bin(result4)[2:].zfill(32)}")

if __name__ == "__main__":
    print("颠倒二进制位算法测试\n")
    test_reverse_bits() 